﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace GLYFrom.TCGL
{
    public partial class CP_update : Form
    {
        public CP_update()
        {
            InitializeComponent();
        }
        int id = 0;
        public CP_update(int a)
        {
            id = a;
            InitializeComponent();
        }
        private void TC_update_Load(object sender, EventArgs e)
        {
            DataTable table = DBHelper.select(string.Format("select * from T_CaiPin where CPId='{0}'",id));
            DataRow row = table.Rows[0];
            this.text_Name.Text = row["Name"].ToString();
            this.combo_Class.Text = row["Class"].ToString();
            this.text_JiaGe.Text = row["JiaGe"].ToString();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string Name = this.text_Name.Text.Trim();
            string Class = this.combo_Class.Text.Trim();
            string JiaGe = this.text_JiaGe.Text.Trim();
            if (Name.Length > 0 && Class.Length > 0 && JiaGe.Length > 0)
            {
                int sr = DBHelper.ZSG(string.Format("update CaiPin set Name='{0}',Class='{1}',JiaGe='{2}' where CPId='{3}'", Name, Class, JiaGe,id));
                if (sr > 0)
                {
                    MessageBox.Show("修改成功！");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("修改失败！");
                }
            }
            else
            {
                MessageBox.Show("修改失败,请填写完整！");
                return;
            }
        }
    }
}
